/*
 * @Author: SimonCK666 SimonYang223@163.com
 * @Date: 2022-05-06 14:32:33
 * @LastEditors: SimonCK666 SimonYang223@163.com
 * @LastEditTime: 2022-05-06 14:41:58
 * @FilePath: \golang-concept\L1_goFlow\break.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package main

import "fmt"

func break_opt() {
	x := [...]int{1, 2, 3}
	flag := 1

	for i := 0; i < len(x); i++ {
		fmt.Printf("I: %v V: %v\n", i, x[i])
		if flag == 1 {
			break // 退出循环
		}
	}

	switch flag {
	case 1:
		fmt.Println("1")
		// break
		fallthrough
	case 2:
		fmt.Println("2")
	}

MYLABLE:
	for i := 0; i < len(x); i++ {
		fmt.Printf("I: %v V: %v\n", i, x[i])
		if flag == 1 {
			break MYLABLE // 退出到 MYLABLE
		}
	}
	fmt.Println("END..")
}
